const loginform = document.querySelector("#loginform");

loginform.onsubmit = async function(e){
    loginwarning.style.display = "none";
    e.preventDefault();
    // console.log(username.value,password.value);
    let res = await fetch(`http://localhost:3000/users?username=${username.value}&password=${password.value}`)
    .then(res=>res.json())
    // console.log(res);
    if(res.length>0){
        localStorage.setItem("token",JSON.stringify({
            ...res[0],
            password:'********'
        }))
        location.href = "/admin/views/home/index.html"
    }else{
        loginwarning.style.display = "block";
    }
}